package com.wnxy.common.result;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author yellow Docter
 * @date 2024 -04-17
 * @desc
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class Result {

    private Integer code;
    private String message;
    private Object data;

    public static Result ok(Integer code,String message,Object data){
        Result result = new Result(code, message, data);
        return result;
    }
    public static Result ok(String message,Object data){
        return ok(200, message, data);
    }

    public static Result ok(){
        return ok(200, "操作成功", null);
    }

    public static Result ok(Object data){
        return ok( "成功", data);
    }

    public static Result fail(Integer code,String message,Object data){
        Result fail = new Result(code, message, data);
        return fail;
    }
    public static Result fail(String message,Object data){
        return fail(400, message, data);
    }

    public static Result fail(Object data){
        return fail( "失败", data);
    }
}
